﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using Commlibrary;

namespace StockAnalyse
{
    public partial class frmConfig : DevComponents.DotNetBar.Office2007Form
    {
        private String m_sDataSource = string.Empty;
        private String m_sUserName = string.Empty;
        private String m_sPassword = string.Empty;

        public frmConfig()
        {
            InitializeComponent();
        }

        private void btnTest_Click(object sender, EventArgs e)
        {
            //SQLHelp.TestDBConnect();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {

        }

        private void txtDataSource_Validating(object sender, CancelEventArgs e)
        {
            String sTmpDataSource = this.txtDataSource.Text;
            if (this.m_sDataSource.Length > 0 && !this.m_sDataSource.Equals(sTmpDataSource) ||
                this.m_sDataSource.Length == 0)
            {
                this.GetDBList();
                this.m_sDataSource = sTmpDataSource;
            }
        }

        private void txtUserName_Validating(object sender, CancelEventArgs e)
        {
            String sTmpUserName = this.txtUserName.Text;
            if (this.m_sUserName.Length > 0 && !this.m_sUserName.Equals(sTmpUserName) ||
                this.m_sUserName.Length == 0)
            {
                this.GetDBList();
                this.m_sUserName = sTmpUserName;
            }
        }

        private void txtPassword_Validating(object sender, CancelEventArgs e)
        {
            String sTmpPassword = this.txtPassword.Text;
            if (this.m_sPassword.Length > 0 && !this.m_sPassword.Equals(sTmpPassword) ||
                this.m_sPassword.Length == 0)
            {
                this.GetDBList();
                this.m_sPassword = sTmpPassword;
            }
        }

        private void GetDBList()
        {
            /*

            ArrayList arrDBList = SQLHelp.GetDataBaseList(
                this.txtDataSource.Text,
                this.txtUserName.Text,
                this.txtPassword.Text);

            this.cboDataBase.Items.Clear();
            if (arrDBList.Count > 0)
            {
                for (int iLoop = 0; iLoop < arrDBList.Count; iLoop++)
                {
                    this.cboDataBase.Items.Add(arrDBList[iLoop]);
                }
            }
             * */
        }

        //SQLDMO.SQLServer srv = new SQLDMO.SQLServerClass(); srv.Connect(this.cboServers.SelectedItem.ToString(),this.txtUser.Text,this.txtPassword.Text); 
    }
}
